PIC24F
PMP Peripheral Module Library Help
Table Of Contents
2 Using Library Functions in Your Code
4.4 mPMPClearBufferUnderflow()
4.9 mPMPSetByteEnablePolarity(polarity)
4.11 mPMPSetChipSelectMode(mode)
4.12 mPMPSetChipSelect1Enable(mode)
4.13 mPMPSetChipSelect1Polarity(polarity)
4.14 mPMPSetChipSelect2Polarity(polarity)
4.16 mPMPSetInterruptEnable(mode)
4.17 mPMPSetInterruptPriority(priority)
4.20 mPMPSetInterruptMode(mode)
4.21 mPMPSetAddrLatchPolarity(polarity)
4.25 mPMPSetReadStrobeEnable(mode)
4.26 mPMPSetReadStrobePolarity(polarity)
4.30 mPMPSetWriteStrobeEnable(mode)
4.31 mPMPSetWriteStrobePolarity(polarity)
4.32 mPMPSetChipSelect2Enable(mode)
This peripheral library module:
· Is a parallel 8-bit I/O module. PMP stands for Parallel Master Port module.
· Is specifically designed to communicate with a wide variety of parallel devices, such as communications peripherals, LCDs, external memory devices and microcontrollers.
· Is highly configurable, since the interface to parallel peripherals varies significantly.
Library routine parameters can be constructed using either AND based mask or AND_OR based mask setting. For more information on these masks, see 16-bit Peripheral Libraries.
Example of Use ( AND_OR mask )
Function Call:
PMPOpen((BIT_PMP_ON | BIT_FRZ_OFF | BIT_SIDL_OFF | BIT_ADDR_MUX_16_8 |
BIT_BE_ON | BIT_RD_WR_ON | BIT_USE_CS2_CS1 | BIT_LATCH_LO |
BIT_CS2_HI | BIT_BE_HI | BIT_RD_HI),
(BIT_IRQ_BUF | BIT_INC_ADDR_AUTO |
BIT_DATA_16 | BIT_MODE_MASTER_1 | BIT_WAITB_4_TCY |
BIT_WAITM_15_TCY | BIT_WAITE_4_TCY),
(BIT_P_ALL) , (BIT_A0) ,
(BIT_INT_PRI_3 | BIT_INT_OFF));
Function Prototype |
void PMPClose(void); |
Include |
pmp.h |
Description |
Disables PMP module and disables interrupt. |
Arguments |
None |
Return Value |
None |
Remarks: |
PMCON.PMPEN, IEC2.PMPIE, IFS2.PMPIF are cleared. |
Source File: |
PMPClose.c |
Function Prototype |
BOOL PMPIsBufferNEmpty(BUFFER buf); |
Include |
pmp.h |
Description |
Returns state of PMSTAT.OBxE (output buffer(s) empty bit) |
Arguments |
buf - (0..3) enum BUFFER is defined in pmp.h. |
Return Value |
TRUE/FALSE |
Remarks: |
Use in SLAVE BUFFERED mode, MODE[1:0] = 00 or SLAVE ENHANCED mode, MODE[1:0] = 00 and INCM[1:0]=11. |
Source File: |
PMPIsBufferNEmpty.c |
Function Prototype |
BOOL PMPIsBufferNFull(BUFFER buf); |
Include |
pmp.h |
Description |
Returns state of PMSTAT.IBxF (input buffer(s) full bit). |
Arguments |
buf - (0..3) enum BUFFER is defined in pmp.h. |
Return Value |
TRUE/FALSE |
Remarks: |
Use in SLAVE BUFFERED mode, MODE[1:0] = 00 or SLAVE ENHANCED mode, MODE[1:0] = 00 and INCM[1:0]=11 |
Source File: |
PMPIsBufferNFull.c |
Function Prototype |
void PMPOpen (UINT control, UINT mode, UINT port, UINT addrs, BYTE interrupt); |
Include |
pmp.h |
Description |
Configures the PMP module as per the input data. Provides method for setting PMP registers using bit masks provided in this header file. |
Arguments |
control - Control register settings mode - Parallel port mode register setting port - Parallel port enable register setting addrs - Parallel port address register content interrupt - intereupt setting for PMP bit [0:2] - priority setting bit [3] - Interrupt Enable/Disable bit [4:7] - unsused |
Return Value |
None |
Remarks: |
None |
Source File: |
PMPOpen.c |
Function Prototype |
WORD PMPMasterRead (void); |
Include |
pmp.h |
Description |
Reads an external device. |
Arguments |
None |
Return Value |
Returns value read from external device. |
Remarks: |
Use in MASTER mode 1 or 2, MODE[1:0] = 10, 11. |
Source File: |
PMPMasterRead.c |
Function Prototype |
void PMPMasterWrite(WORD value); |
Include |
pmp.h |
Description |
If 8-bit data mode is selected, the data appears on 8 data lines. If 16-bit data mode is selected, the lower 8 bits of data are written first, followed by the upper 8 bits of data. |
Arguments |
value - data to write to external device |
Return Value |
None |
Remarks: |
Use in MASTER mode 1 or 2, MODE[1:0] = 10, 11. |
Source File: |
PMPMasterWrite.c |
Function Prototype |
void PMPSetAddress(WORD addrs); |
Include |
pmp.h |
Description |
Sets the address that will appear on the PMP bus addrs lines. |
Arguments |
addrs - address that needs to appear on the bus |
Return Value |
None |
Remarks: |
Use in MASTER mode 1 or 2, MODE[1:0] = 10, 11. |
Source File: |
PMPSetAddress.c |
Function Prototype |
void PMPSlaveReadBuffers(BYTE* ref); |
Include |
pmp.h |
Description |
Copies 4 bytes from DATAIN buffers to a starting location pointed to by the input parameter. |
Arguments |
ref - BYTE pointer to application buffer |
Return Value |
The contents of the (4) 8-bit slave buffer registers. |
Remarks: |
Reading any of these buffers clears the IBF status bit as well as the individual IBnF status bits. Use in MASTER mode 1 or 2, MODE[1:0] = 10, 11. |
Source File: |
PMPSlaveReadBuffers.c |
Function Prototype |
BYTE PMPSlaveReadBufferN(BUFFER buf) |
Include |
pmp.h |
Description |
Reads the value in PMDATA register written by a master device. |
Arguments |
buf - (0..3) enum BUFFER is defined in pmp.h. |
Return Value |
The value in selected buffer register. |
Remarks: |
Reading PMDATA buffer clears status bit. Use in SLAVE BUFFERED mode, MODE[1:0] = 00 and INCM[1:0]=11 or SLAVE ENHANCED mode, MODE[1:0] = 01. |
Source File: |
PMPSlaveReadBufferN.c |
Function Prototype |
BOOL PMPSlaveWriteBuffers(BYTE* ref); |
Include |
pmp.h |
Description |
Copies 4 bytes, addressed by the pointer/ref argument, into the corresponding output registers. Byte[0] -> OUT1[7:0], byte[1] -> OUT1[15:8], etc. If the entire buffer is empty, (IBF = 0) function returns TRUE; else the bytes are not copied and returns FALSE. |
Arguments |
ref - BYTE pointer to application buffer. |
Return Value |
Returns TRUE if successful, else FALSE. |
Remarks: |
Use in SLAVE BUFFERED mode, MODE[1:0] = 00 and INCM[1:0]=11 or SLAVE ENHANCED mode, MODE[1:0] = 01. |
Source File: |
PMPSlaveWriteBuffers.c |
Function Prototype |
BOOL PMPSlaveWriteBufferN(BUFFER buf, BYTE); |
Include |
pmp.h |
Description |
Writes the desired value into the selected output buffer. |
Arguments |
buf - (0..3) enum BUFFER is defined in pmp.h. |
Return Value |
Returns TRUE if successful, else FALSE. |
Remarks: |
Use in SLAVE BUFFERED mode, MODE[1:0] = 00 and INCM[1:0]=11 or SLAVE ENHANCED mode, MODE[1:0] = 01. |
Source File: |
PMPSlaveWriteBufferN.c |
Macro |
mPMPIsBufferFull() |
Include |
PwrMgnt.h |
Description |
Returns state of PMSTAT.IBF (input buffer full bit) TRUE = All writable input buffer registers are full FALSE = Some or all of the writable input buffer registers are empty |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPIsBufferOverflow() |
Include |
PwrMgnt.h |
Description |
Returns state of PMSTAT.IBOV (input buffer overflow bit) TRUE = A write attempt to a full input byte register occurred (must be cleared in software) FALSE = No overflow occurred |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPClearBufferOverflow() |
Include |
PwrMgnt.h |
Description |
Clears PMSTAT.IBOV (input buffer overflow bit) |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPClearBufferUnderflow() |
Include |
PwrMgnt.h |
Description |
Clears PMSTAT.OBUF (output buffer underflow bit) |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPIsBufferEmpty() |
Include |
PwrMgnt.h |
Description |
Returns state of PMSTAT.OBE (output buffer empty bit) TRUE = All readable output buffer registers are empty FALSE = Some or all of the readable output buffer registers are full |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPIsBufferUnderFlow() |
Include |
PwrMgnt.h |
Description |
Returns state of PMSTAT.OBUF (output buffer underflow bit) TRUE = A read occurred from an empty output byte register (must be cleared in software) FALSE = No underflow occurred |
Arguments |
None |
Remarks |
Use in any SLAVE mode |
Macro |
mPMPSetAddrIncMode(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP address inc/dec mode |
Arguments |
mode - 0= no inc/dec, 1= inc, 2= dec, 3= PSP buffered. |
Remarks |
None |
Macro |
mPMPSetADRMux(mux) |
Include |
PwrMgnt.h |
Description |
Selects PMP addrs/data multiplexing mode |
Arguments |
mux - 0= no mux, 1= 8addr/8data muxed, 2= 16addr/8data muxed. |
Remarks |
None |
Macro |
mPMPSetByteEnablePolarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP byte enable pin polarity |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetByteEnable(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP byte enable bit |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |
Macro |
mPMPSetChipSelectMode(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP byte enable bit |
Arguments |
mode - 0= CS2 as A15,CS1 as A14; 1= CS2 as CS2, CS1 as A14; 2= CS2 as CS2, CS1 as CS1; 3= reserved. |
Remarks |
None |
Macro |
mPMPSetChipSelect1Enable(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP chip select 1 pin polarities. |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |
Macro |
mPMPSetChipSelect1Polarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP chip select pin polarities. |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetChipSelect2Polarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP chip select pin polarities. |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetDataMode(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP data width to 8 or 16 bit. |
Arguments |
mode - 0=8-bit, 1=16-bit. |
Remarks |
None |
Macro |
mPMPSetInterruptEnable(mode) |
Include |
PwrMgnt.h |
Description |
Sets/clears PMP interrupt enable bit. |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |
Macro |
mPMPSetInterruptPriority(priority) |
Include |
PwrMgnt.h |
Description |
Sets/clears PMP interrupt priority bits. |
Arguments |
priority - 0 through 7. |
Remarks |
None |
Macro |
mPMPSetFreeze(mode) |
Include |
PwrMgnt.h |
Description |
Sets/clears PMP debugging freeze bit. |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |
Macro |
mPMPSetIdle(mode) |
Include |
PwrMgnt.h |
Description |
Sets/clears PMP "STOP IN IDLE" mode bit. |
Arguments |
mode - 0=ENABLED, 1=DISABLED. |
Remarks |
None |
Macro |
mPMPSetInterruptMode(mode) |
Include |
PwrMgnt.h |
Description |
Selects PMP interrupt mode. |
Arguments |
mode - 0=no INT, 1=INT on R/W, 2=INT on buffer full, 3= reserved. |
Remarks |
None |
Macro |
mPMPSetAddrLatchPolarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP address latch pin polarity. |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetPortEnable(mode) |
Include |
PwrMgnt.h |
Description |
Sets/clears PMP module enable bit. |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |
Macro |
mPMPSetPortMode(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP mode of operation as a slave or master. |
Arguments |
mode - 0= PSP legacy, 1= PSP enhanced, 2= Master2, 3= Master1. |
Remarks |
None |
Macro |
mPMPSetPortPins(value) |
Include |
PwrMgnt.h |
Description |
Sets PMP addrs, latch and CS pins as either functional or I/O. |
Arguments |
value - 0000h-FFFFh. |
Remarks |
None |
Macro |
mPMPSetReadStrobeEnable(mode) |
Include |
PwrMgnt.h |
Description |
Sets/clears Read/Write Strobe Port Enable bit. |
Arguments |
mode - 1 = PMRD/PMWR port enabled 0 = PMRD/PMWR port disabled |
Remarks |
None |
Macro |
mPMPSetReadStrobePolarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP read pin polarity. |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetWaitBegin(wait) |
Include |
PwrMgnt.h |
Description |
Sets PMP beginning phase wait time. |
Arguments |
wait - (0..3) cycles. |
Remarks |
None |
Macro |
mPMPSetWaitMiddle(wait) |
Include |
PwrMgnt.h |
Description |
Sets PMP middle phase wait time. |
Arguments |
wait - (0..15) cycles. |
Remarks |
None |
Macro |
mPMPSetWaitEnd(wait) |
Include |
PwrMgnt.h |
Description |
Sets PMP end phase wait time. |
Arguments |
wait - (0..3) cycles. |
Remarks |
None |
Macro |
mPMPSetWriteStrobeEnable(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP Write Enable Strobe Port Enable bit. |
Arguments |
mode - 1 = PMWR/PMENB port enabled 0 = PMWR/PMENB port disabled |
Remarks |
None |
Macro |
mPMPSetWriteStrobePolarity(polarity) |
Include |
PwrMgnt.h |
Description |
Sets PMP write pin polarity. |
Arguments |
polarity - 0= active lo, 1= active hi. |
Remarks |
None |
Macro |
mPMPSetChipSelect2Enable(mode) |
Include |
PwrMgnt.h |
Description |
Sets PMP chip select 2 pin. |
Arguments |
mode - 0=DISABLED, 1=ENABLED. |
Remarks |
None |